package com.sa.web.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import com.sa.web.bean.UserBean;
import com.sa.web.bean.StuInfoBean;
import com.sa.web.dao.service.UserInfoDao;

public class UserInfoDaoImpl implements UserInfoDao{
	
	private SqlMapClientTemplate sqlMapClientTemplate;

	/**
	 * 获得管理员信息列表
	 */
	@Override
	public List<UserBean> getUserInfoList(String UserName,int start,int size) {
		Map<String,Object> map = new HashMap<String,Object> ();
		map.put("UserName", UserName);
		map.put("start", start);
		map.put("size", size);
		return (List<UserBean>)sqlMapClientTemplate.queryForList("getUserInfoList",map);
	}
	
	/**
	 * 删除管理员信息列表
	 */
	public boolean deleteUserInfo(String UserId){
		return sqlMapClientTemplate.delete("deleteUserInfo",UserId)>0;
	}
	/**
	 * 获得管理员信息总数
	 */
	@Override
	public Integer getUserInfoCount(String UserName) {
		Map<String,Object> map = new HashMap<String,Object> ();
		map.put("UserName", UserName);
		return (Integer)sqlMapClientTemplate.queryForObject("getUserInfoCount",map);
	}
	
	/**
	 * 获得单条管理员信息
	 */
	@Override
	public UserBean getUserInfo(String UserId) {
		return (UserBean)sqlMapClientTemplate.queryForObject("getUserInfo", UserId);
	}
	
	/**
	 * 增加管理员信息
	 */
	@Override
	public boolean addUserInfo(UserBean UserInfo) {
		return (Integer)sqlMapClientTemplate.insert("addUserInfo", UserInfo)>0;
	}
	/**
	 * 修改管理员信息
	 */
	@Override
	public boolean updateUserInfo(UserBean UserInfo) {
		return sqlMapClientTemplate.update("updateUserInfo", UserInfo)>0;
	}

	public SqlMapClientTemplate getSqlMapClientTemplate() {
		return sqlMapClientTemplate;
	}

	public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) {
		this.sqlMapClientTemplate = sqlMapClientTemplate;
	}

}
